Developing the first coinflow app, step 1
This article assumes you understand the gist of how netvend's four basic commands work. If not, see Using the netvend api. Summary The first step of developing the coinflow app should focus on creating a basic, functional interface to communicate with and follow other netvend agents. This article will explain the necessary features of such a client, and how they can be achieved through netvend. The basic coinflow app should allow users to: #create an agent #fund the user's agent #post a message to the network #follow specific agents #generate a feed, based on followed agents #tip specific agents (or specific posts) #join "channels" As you'll see, the first two steps are actually the most difficult, in terms of design and making the steps easy for the user. The actual social activity of the program is extremely simple to design. This is representative of netvend's particular strength: Given that an agent has credit, it's extremely simple to access netvend in many different ways. Interface design At first, the interface will be similar to that seen in a lot of IRC clients: most of the window is taken up by the text feed, and there's also a single-line text input both for messages, and for entering commands preceded by a slash (/follow, /block, etc.). This will allow rapid development of new features, without having to worry too much about how the design should change to accommodate each one. When it's easy to implement, right-click actions could be added to make certain commands less tedious. For example, right click to copy an address or post from the feed, tip a post, block/whisper someone, etc. Create an agent Because netvend uses keypairs for authentication, rather than login information, this part of the user interface may be somewhat troublesome to make easy-to-use. As far as ease of design goes, the simplest thing may be to have an /agentseed command, which simply takes a seed directly to create an agent. This would require that a user keep track of their own seeds and manually copy/paste from some maintained list of seeds, so it shouldn't be a long-term solution. However, it's functional enough to get a user started fairly easily--and if the user is only handling a few satoshis, the lack of security is not as big of a concern. By adding a way to save and load agents (with optional encryption via a passphrase), this strategy becomes much more user-friendly. For example, perhaps the user can type /saveagent name, which creates a popup asking for an encryption phrase, typed twice to protect against typos. The agent seed is then encrypted and saved as a file with name. Then /loadagent name could load that agent, and a popup could ask for the encryption phrase to decrypt the seed used. /listagents could list all saved agents, if the user forgot what they named it. fund the user's agent To further complicate things, an agent has to have credit to access netvend. One problem is that the method of deposits is a bit convoluted at the moment--see this page for more info on this. Until deposits are made more convenient (see developing a netvend deposit service), credit will be given out to any interested users. Even so, this adds another speedbump for an initial user. We'll have to rely on giveaway threads, faucets, etc. to fund new users. A user should have a command (like simply /getaddress) that shows them their public address, which they'll need to get initial credit. On the bright side, any user with funds can send a bit to any of their friends, which effectively lets anyone already on netvend invite any of their friends to use it as well. Because netvend fees are on the order of 1/1000 of a satoshi, even giving a millibitcoin of credit to an interested user will enable that user to "invite" a large number of their friends, who themselves will likely have enough credit to share with their own friends. Post a message to the network After an agent has been created and funded, the rest of the program's operation is pretty simple. To post a message a user typed into the text entry box, simply call the agent.post method of the netvend api, after setting up an agent with the user's supplied seed. response = agent.post(post_prefix+message) Follow other agents If a user types /follow agent address, this is again a very simple feature to support. Simply add the address to a saved list, which we'll call followed_agents, and use in generating a feed, below. Fetching a feed To generate a feed for the user, simply use the agent's query command, with a query similar to the following: query = "SELECT address, data, ts FROM posts WHERE address IN ('" + followed_agents.join("', '") + "')" response = agent.query(query) For those that are unfamiliar with SQL, this selects the columns adddress, data, and ts (timestamp) from the posts table, for all posts authored by anyone in our followed_agents list. Tipping users/posts Facilitating tipping among users is pretty simple. Just call agent.tip(recipient_address, amount, post_id). Amount is in uSats, and post_id should be used if the user wants to tip in response to a specific post (otherwise, can be None). The next step At this point, we'd have a basic, functional IRC-like communication tool. It works, but it doesn't do anything special, and is pretty barren. This serves as a base to begin adding the exciting features--the ones that netvend is especially suited to provide. For more on this, see Developing the first coinflow app, step 2.